package cheme.ProcessModel.Interpreter;

import org.eclipse.draw2d.geometry.Rectangle;

import cheme.ProcessModel.ConsoleModel;
import cheme.ProcessModel.ConsoleView;
import cheme.ProcessModel.HelloModel;
import cheme.ProcessModel.IModelElement;
import cheme.ProcessModel.ModelEnv;
import cheme.ProcessModel.ProcessModel;
import cheme.ProcessModel.ProcessModelConstants;
import cheme.ProcessModel.SolvabilityStatus;
import cheme.ProcessModel.TooltipModel;
import cheme.ProcessModel.Equations.Equation;
import cheme.ProcessModel.Equations.EquationField;
import cheme.ProcessModel.Equations.EquationList;
import cheme.ProcessModel.Equations.Equations;
import cheme.ProcessModel.ProcessUnits.Mixer;
import cheme.ProcessModel.ProcessUnits.Separator;
import cheme.ProcessModel.ProcessUnits.TerminalSink;
import cheme.ProcessModel.ProcessUnits.TerminalSource;
import cheme.ProcessModel.ProcessUnits.Streams.Stream;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.OverallTagComponent;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.Tag;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.TagComponent;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.TagComponentList;
import cheme.ProcessModel.Table.Field;

public class ModelFactory //implements IModelFactory
{
	public static IModelElement createModelElement(String type, IModelElement parent)
	{
		ModelEnv env = ModelEnv.getInstanceFor(parent);
		
		if(type.equals(ProcessModelConstants.PROCESS_MODEL))
		{
			return new ProcessModel(parent);
		}
		else if(type.equals(ProcessModelConstants.PROCESS_UNIT_MIXER))
		{
			return new Mixer(parent);
		}
		else if(type.equals(ProcessModelConstants.PROCESS_UNIT_SEPARATOR))
		{
			return new Separator(parent);
		}
		else if(type.equals(ProcessModelConstants.PROCESS_UNIT_TERMINAL_SOURCE))
		{
			return new TerminalSource(parent);
		}
		else if(type.equals(ProcessModelConstants.PROCESS_UNIT_TERMINAL_SINK))
		{
			return new TerminalSink(parent);
		}
		else if(type.equals(ProcessModelConstants.STREAM))
		{
			Stream child =  new Stream(parent);
//			env.hookModelElement(child);
			return child;
		}
		else if(type.equals(ProcessModelConstants.TAG))
		{
			Tag child = new Tag(parent);
//			env.hookModelElement(child);
			return child;
		}
		else if(type.equals(ProcessModelConstants.TAG_COMPONENT))
		{
			TagComponent child = new TagComponent(parent);
//			env.hookModelElement(child);
			return child;
		}
		else if(type.equals(ProcessModelConstants.TAG_OVERALL))
		{
			OverallTagComponent child = new OverallTagComponent(parent);
			env.initializeOverallTagComponent(child);
//			env.hookModelElement(child);
			return child;
		}
		else if(type.equals(ProcessModelConstants.TAG_COMPONENT_LIST))
		{
			TagComponentList child = new TagComponentList(parent);
//			env.hookModelElement(child);
			return child;
		}
		else if(type.equals(ProcessModelConstants.EQUATION))
		{
			Equation child = new Equation(parent);
//			env.hookModelElement(child);
			return child;
		}
		else if(type.equals(ProcessModelConstants.EQUATION_LIST))
		{
			EquationList child = new EquationList(parent);
//			env.hookModelElement(child);
			return child;
		}
		else if(type.equals(ProcessModelConstants.EQUATIONS))
		{
			return new Equations(parent);
		}
		else if(type.equals(ProcessModelConstants.FIELD))
		{
			return new Field(parent, "");
		}
		else if(type.equals(ProcessModelConstants.EQUATION_FIELD))
		{
			return new EquationField(parent, "");
		}
		else if(type.equals(ProcessModelConstants.OPERATOR_FIELD))
		{
//			return new OperatorField(parent, "");
		}
		else if(type.equals(ProcessModelConstants.PALETTE_FIELD))
		{
//			return new PaletteField();
		}
		else if(type.equals(ProcessModelConstants.SOLVABILITY_STATUS))
		{
			SolvabilityStatus child =  new SolvabilityStatus(parent);
			
			return child;
		}
		else if(type.equals(ProcessModelConstants.CONSOLE_VIEW))
		{
			ConsoleView child =  new ConsoleView(parent);
			
			return child;
		}
		else if(type.equals(ProcessModelConstants.TOOLTIPMODEL))
		{
			return (TooltipModel.getInstance(parent));			
		}
	
		return null;
	}
}
